package aex.util;

import java.util.Set;
import java.util.TreeSet;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.StrutsStatics;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
/**
 * 管理员包拦截器
 * @author JiangYouYao
 */
public class PublicInterceptor implements Interceptor {

	private static final long serialVersionUID = -5178310397732210602L;

	public void destroy() {
	}

	public void init() {
	}

	public String intercept(ActionInvocation invocation) throws Exception {
		
		ActionContext actionContext = invocation.getInvocationContext();
		HttpServletRequest request = (HttpServletRequest) actionContext
				.get(StrutsStatics.HTTP_REQUEST);
		CU.deBugPrintln("进入拦截器"+request.getRequestURI());
		
		String path=request.getRequestURI();
		
		
		
		
		
		
		boolean flag=true;
		
		if(null == request.getHeader("Referer")
				//||request.getHeader("Referer").indexOf("yourdomain.com")<0
				){
			flag=false;
		}

		if (flag) {
			CU.deBugPrintln("拦截器放行");
			return invocation.invoke();
		} else {
			CU.deBugPrintln("拦截器禁止同通行！");
			return "index";
		}
		
		
	}


}
